<div class="content border_box" style="background: #ffffff;">
    <div class="content-padded">
        <div class="row no-gutter" style="padding: 0px;text-align: center;">
            <div class="col-25 catlist " style="margin-top: 10px;">
                <{foreach from=$parents item=parent key=key}>
                    <a href="#tab<{$parent.cat_id}>" class="tab-link active cat <{if $key==0}>catactive<{/if}>" catname="<{$parent.cat_name}>">
                        <{$parent.title1}><br>
                        <{$parent.title2}>
                    </a>
                <{/foreach}>
            </div>
            <div class="col-75 listbox" style="padding-top: 0.75rem;height: 90%;overflow:auto;">
                <div class="tabs" style="width: 100%;">
                    <{assign var="do" value="0" }>
                    <{foreach from=$subcats item=subcat key=key}>
                        <{assign var="do" value=$do+1}>
                        <div id="tab<{$key}>" class="tab <{if $do==1}>active<{/if}>">
                            <div class="tab_img" data-pcatIds="<{$key}>">
                                <{if $parents.$key.cat_nameNoChakan !=1}>
                                    <{if $parents.$key.virtualLink}>
                                    <a href="<{$parents.$key.virtualLink}>" class="tab_img_button" data-catid="<{$key}>">查看全部＞</a>
                                    <{else}>
                                    <a href="<{link app=b2c ctl=wap_gallery act=index arg0=$key}>" class="tab_img_button" data-catid="<{$key}>">查看全部＞</a>
                                    <{/if}>
                                <{/if}>
                            </div>
                            <ul>
                            <{foreach from=$subcat item=item key=k}>
                            <{if $item.echoTitle ==1}>
                            <div class="cat-order">
                                <{if $item.cat_titleSon}>
                                    <{foreach from=$item.cat_titleSon item=cat_titleSon key=keySon}>
                                        <{if $keySon == 0}>
                                            <div class="son-div1">
                                                <span class="line"></span>
                                                <span class="txt"><{$cat_titleSon}></span>
                                                <span class="line"></span>
                                            </div>
                                        <{else}>
                                            <div class="son-div2">
                                                <span class="txt2"><{$cat_titleSon}></span>
                                            </div>
                                        <{/if}>
                                    <{/foreach}>
                                <{else}>
                                    <span class="line"></span>
                                    <span class="txt"><{$item.cat_title}></span>
                                    <span class="line"></span>
                                <{/if}>
                            </div>
                            <{/if}>
                                <li class="type_content_box float_l">
                                    <{if $item.virtualLink}>
                                    <a href="<{$item.virtualLink}>" class="type_content">
                                        <{$item.cat_name}>
                                    </a>
                                    <{else}>
                                    <a href="<{link app=b2c ctl=wap_gallery act=index arg0=$item.cat_id}>" class="type_content">
                                        <{$item.cat_name}>
                                    </a>
                                    <{/if}>
                                </li>
                            <{/foreach}>
                            </ul>
                        </div>
                    <{/foreach}>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
$(".cat").click(
    function() {
        $(".cat").removeClass("catactive")
        $(this).addClass("catactive")
    }
)
// $('.tab_img_button').on('click',function(){
//     var cat_id = $(this).attr('data-catid');
//     var cat_name = $('.tab-link.catactive').attr('catname');
//     var url = '<{link app=b2c ctl=wap_gallery act=index arg0="'+cat_id+'" arg1="'+cat_name+'"}>';
//     $(this).attr('href',url);
// })
$('.type_content').on('click', function() {
    $('.type_content').removeClass('type_content_now');
    $(this).addClass('type_content_now');
});
$('.tabs .tab_img').each(function(i){
    var catId = $(this).attr('data-pcatIds');
    $(this).prepend('<{img src="images/type_show'+catId+'.jpg" app="wap" }>');
});
// console.log(aaa);
String.prototype.trim=function(){
　   return this.replace(/(^\s*)|(\s*$)/g, "");
}
window.onload = function() {
    var aaa = $('.type_content');
    aaa.each(function(index, el) {
        var str =$(el).text();
        str = str.trim();
        var realLength = 0, len = str.length, charCode = -1;
        for (var i = 0; i < len; i++) {
            charCode = str.charCodeAt(i);
            if (charCode >= 0 && charCode <= 255){
                realLength += 1;
            }else{
                realLength += 2;
            }
        }
        // if ((realLength>14 && $(el).width()==0) || $(el).width()>124) {
        //     $(el).css('line-height','0.7rem');
        //     console.log($(el).width());
        // }
        if (realLength>=13 || (realLength>13 && $(el).width()==0)) {
            $(el).css('line-height','0.8rem');
            console.log($(el).width());
        }
}   );
}

</script>